<?php
session_start();
	
if ( (session_is_registered('sesId') || session_is_registered('cvecliente')) ){
	if (session_is_registered('PEDFLE') && session_is_registered('cvetipoventa')){
			session_unregister('PEDFLE');
			require('templates/func_cliente_pedido.php');
			$fletes=Listado_Fletes_Pedido();
			$varcliente=$_SESSION['cvecliente'];
			
			$matrizcliente=explode("|",Consulta_Cliente_Pedido($varcliente));
			$clavesesion=$_SESSION['sesId'];
			$nombreSocio="";
			if ($_SESSION['tipousuario']=='C' || $_SESSION['tipousuario']=='F'){
				//// Si la persona logueada es cliente, se obtiene el numero del socio
				if($_SESSION['cvesocio']>0){
					$nombreSocio=Obtener_Informacion_Socio($_SESSION['cvesocio']);
				}
				
			}
		
			$fechaInicio=date("Y-m-d");


								$clavecliente=$_SESSION['cvecliente'];
								$logincliente=$_SESSION['clavecte'];
								$clavesocio=$_SESSION['cvesocio'];
								$sql="select codigo,cantidad,precio,descuento,surtido,importe,equivale,'DEL' as borrar,descripcion,aplicacion from swpr_pedidos where cliente=$clavecliente and socio = $clavesocio  and trim(clavecte)=trim('$logincliente') order by id_serial ";
		

								$name = "obj";
								$grid=activewidgets_grid($name, $sql);



			?>
			<html xmlns="http://www.w3.org/1999/xhtml">
			<head>
			<meta http-equiv="content-type" content="text/html; charset=UTF-8" />	

			
			<script type="text/javascript" src="javascripts/prototype.js"> </script> 
			<script type="text/javascript" src="javascripts/effects.js"> </script>
			<script type="text/javascript" src="javascripts/window.js"> </script>
			<script type="text/javascript" src="javascripts/window_effects.js"> </script>

			<script type="text/javascript" src="javascripts/debug.js"> </script>
			
			<link href="themes/default.css" rel="stylesheet" type="text/css" >	 </link>
			<link href="themes/alphacube.css" rel="stylesheet" type="text/css" >	 </link>
			

			<script src="./runtime/lib/aw.js"></script>
			
			<link href="./runtime/styles/xp/aw.css" rel="stylesheet"></link>
			
			<LINK REL="stylesheet" TYPE="text/css" HREF="css/style.css?ms=<?php echo time();?>">
			<!-- -->

			<script src="./templates/cliente_pedido_morsa.js?ms=<?php echo time();?>"></script>	
			<script src='./js/mensajes.js?ms=<?php echo time();?>'></script>

			<title>GRUPO MORSA</title>
			
			<!--Marquesina de pedidos-->

			<link href="modal/facebox.css" media="screen" rel="stylesheet" type="text/css" />

			<script src="js/jquery-1.5.min.js" type="text/javascript" ></script>
                        <script type="text/javascript">
                                jQuery.noConflict();
				jQuery(document).ready(function($) {
					$.getScript('js/jquery.marquee.js', function() {
						
						$('marquee').marquee('pointer').mouseover(function () {
					            $(this).trigger('stop');
					        }).mouseout(function () {
					            $(this).trigger('start');
					        }).mousemove(function (event) {
					            if ($(this).data('drag') == true) {
					                this.scrollLeft = $(this).data('scrollX') + ($(this).data('x') - event.clientX);
					            }
					        }).mousedown(function (event) {
					            $(this).data('drag', true).data('x', event.clientX).data('scrollX', this.scrollLeft);
					        }).mouseup(function () {
					            $(this).data('drag', false);
					        });
						

					});

					$.getScript('modal/facebox.js', function() {
						 $('a[rel*=facebox]').facebox({
        						loadingImage : 'modal/loading.gif',
						        closeImage   : 'modal/closelabel.png'
						  });
					});
				});
                        </script>
			<style>
				marquee{
					margin:0;
					padding:0;
					top:0;
				}
			</style>
			<!-- Fin Marquesina -->

			
			</head>
			<body onload='fnInicializaPedido();'>
			
			<script>
				var index= 0;
				var contentWin = null;
				var win;
				var obj;
				//var options = { script:'buscalineas.php?json=true&', varname:'input', json:true, callback: function (obj) {  alert('simon'); } };
				
			</script>
					<div id="topics">
						<form name="formulario" method="post" enctype="multipart/form-data" action="" >
						<table width="100%" border="0" cellspacing="0" cellpadding="0">
						<tr>
							<td align="left">
								<strong>Venta:</strong>&nbsp;<?php echo Obtener_Tipo_Venta_Descripcion(); ?>
							</td>
							<td align="left">
								 <strong>Flete:</strong>&nbsp;<?php echo Obtener_Flete_Descripcion(); ?>
							</td>
							<td align="left">
								<strong>Cliente:</strong>&nbsp;
							</td>
							<td align="left" colspan='3'>
								<input type='textbox' id='ncliente' name='ncliente' size='5' onkeypress='fnbusca_numcentro()' value='<?php echo $matrizcliente[0]; ?>'>
								<input type='textbox' id='nnombrecliente' name='nnombrecliente' size='100' readonly value='<?php echo $matrizcliente[1]; ?>'>
							</td>
						</tr>
						</table>
					</div>
					
					<!--<span id="contenedor_semaforo" style="margin:0px;" valign="top">&nbsp;-->
					 <!-- &nbsp;<marquee behavior="scroll" direction="left" scrollamount="1" width="750" height="15" id="semaforo">
                                             <?php echo Obtener_semaforo($_SESSION['cvecliente'],$_SESSION['cvesocio']); ?>
                                             </marquee>-->

                                        <!--</span>-->
					<br/>
					<div id="footer"></div>
					<table width="100%" border="0" cellspacing="0" cellpadding="0">
					  <tr>
							<td width="50%" align="left" valign="top">
								<table width="100%" border="0" cellspacing="0" cellpadding="0">
								<tr>
									<td width='250' valign='center'>
										C&oacute;digo:<input type='textbox' id='codigobuscar' name='codigobuscar' size='25' maxlenght='25' onkeypress='fnbusca_codigo_pedido(event);' onkeyup='fnpresionatecla(event);' ><a href='#' onclick='fnMensaje(1);return false;'><img src='img/help.gif' width='8%' align='left' valign='bottom'/></a>
                          <?php
                             //echo $_SERVER['HTTP_USER_AGENT'];
                              //if(preg_match(‘/(up.browser|up.link|mmp|symbian|smartphone|midp|wap|phone|android)/i’,strtolower($_SERVER['HTTP_USER_AGENT']))){
//if(strpos('Android’,$_SERVER['HTTP_USER_AGENT'])){
                           if(preg_match('/(android|ipad|symbian|symos|mobi)/i',$_SERVER['HTTP_USER_AGENT'])){
                              $mobile_browser++;
                              echo "<input type='button' class='b3' name='btcodigobuscar' id='btcodigobuscar' value='Buscar' onClick='fnbusca_codigo_pedido_movil();'>";
                             } 
                          ?>
									</td>
									<td width='200' valign='center'>&nbsp;
										<span id='idcodcant' name='idcodcant'></span>
									</td>
																	<td>&nbsp;</td>
								</tr>
								<tr>
									<td colspan='3' valign='center'>&nbsp;
										<span id='retcodigobuscar' name='retcodigobuscar'></span>
										<span id='returnkits' name='returnkits'></span>
										<span id='returnname' name='returnname'></span>
									</td>
								</tr>
								</table>
															
								
								<span id='idgrid' name='idgrid'>
								<script>
									<?php
									echo $grid; 
									?>
								</script>
								</span>
								<table cellpadding='0' cellspacing='0' border='0' align='left' valign='top'>
								<tr>
									<td  colspan='6'> 
										<span id='datagrid' name='datagrid'>
											<script>
											document.write(obj); 
											</script>
										</span>
									</td>
									<td  width='155px'>
										<input type='button' class='b4' name="btlineas" id="btlineas" value="Catalogo Electr&oacute;nico" onClick="fnventana_filtros(); return false;">
		
										<input type='button' class='b3' name="btlimpiapedido" id="btlimpiapedido" value="Limpiar Pedido" onClick="LimpiarPedido();">
										
										<!-- <input type='button' class='b3' name="btkitspedido" id="btkitspedido" value="Listado de Kits" onClick="fnobtenerkits();"> -->
									
										<input type='button' class='b3' name="btbnombrepedido" id="btbnombrepedido" value="Busqueda por Nombre" onClick="fnobtenerpornombre();">
										
										<input type='button' class='b3' name="btbnombrecoincidencia" id="btbnombrecoincidencia" value="Busqueda por Coincidencias" onClick="fnobtenerporcoincidencias();"> 

									  <input type='button' class='b4' name="btlsugerircodigo" id="btsugerircodigo" value="Sugerir Codigos" onClick="fnventanasugerido();">
										
										<?php if($_SESSION['tipousuario']=='C'){?>
											<input type='button' class='b3' name="btlineas" id="btlineas" value="Pedido por Linea" onClick="fnvetanalineas();">
											
											<input type='button' class='b3' name="btgrabapedido" id="btgrabapedido" value="Enviar Pedido" onClick="VerificaPedido();">
										<?php }?>
									</td>
									<td>
									<!--	<marquee behavior="scroll" direction="left" scrollamount="2" width="350">
									   <?php //echo Obtener_semaforo($_SESSION['cvecliente'],$_SESSION['cvesocio']); ?>
										</marquee>-->
									</td>
									
								</tr>
								<tr>
									<td  colspan='6'>
										<span id='retTotalPedido' name='retTotalPedido'><?php //echo Informacion_Total_Pedido(); ?></span>
									</td>
								</tr>
								</table>
								
							</td>
				
					  </tr>
					</table>
					

			<input type="hidden" name="hdfecinicio" value="<?php echo $fechaInicio; ?>">
			<input type="hidden" name="hdfecinicio" value="<?php echo $fechaInicio; ?>">
			<input type="hidden" name="hdempvalido" value="0">
			<input type="hidden" id="hdCodigoSelEq" name="hdCodigoSelEq" value='88'>
			<input type="hidden" id="hdCodigoBuscarEq" name="hdCodigoBuscarEq" value='88'>
			<input type="hidden" id="hdCodigoBuscarNombre" name="hdCodigoBuscarNombre" value='88'>
			<input type="hidden" id="hdkey" name="hdkey" value='1'>
			<input type="hidden" id="hdeq" name="hdeq" value='1'>
			<input type="hidden" id="hdped" name="hdped" value='1'>
			<input type="hidden" id="hdcodeqnoex" name="hdcodeqnoex" >
			<input type="hidden" id="hdcodeqnoexNo" name="hdcodeqnoexNo" value='1' >
			<input type="hidden" id="hdcodeqnoexSi" name="hdcodeqnoexSi" value='1' >
			</form>

			<script>
				setInterval('fnchecksaveped()',100);
				fnactualizaTotales();
				//var as_json = new AutoSuggest('nombreproveedor', options);
			</script>

			<script type="text/javascript">

  var _gaq = _gaq || [];
  _gaq.push(['_setAccount', 'UA-11434205-15']);
  _gaq.push(['_trackPageview']);

  (function() {
    var ga = document.createElement('script'); ga.type = 'text/javascript'; ga.async = true;
    ga.src = ('https:' == document.location.protocol ? 'https://ssl' : 'http://www') + '.google-analytics.com/ga.js';
    var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(ga, s);
  })();

</script> 
			</body>
			</html>
			<?php
	}else{
			?>
			<HTML>
			<head>

			<script type="text/javascript" src="javascripts/prototype.js"> </script> 
			<script type="text/javascript" src="javascripts/effects.js"> </script>
			<script type="text/javascript" src="javascripts/window.js"> </script>
			<script type="text/javascript" src="javascripts/window_effects.js"> </script>
			<script type="text/javascript" src="javascripts/debug.js"> </script>
			<link href="themes/default.css" rel="stylesheet" type="text/css" >	 </link>
			<link href="themes/alphacube.css" rel="stylesheet" type="text/css" >	 </link>

			</head>
			<body>
			<script>
				var index= 0;
				var contentWin = null;
				
				win = new Window('dialog1', {className: "alphacube",  width:320, height:150, zIndex: 100, resizable: false, scrollbars: false, url: "ped_tipo_venta.php", title: "Tipo de Venta y Flete", showEffect:Element.show, hideEffect: Effect.SwitchOff, draggable:false})
				win.showCenter();
					
			</script>
			</body>
			</html>
			<?php
	}
}else{
	header("LOCATION:index.php");
}
?>
